import store from '@/stores/index.js'
const baseUrl = 'http://124.93.196.45:10001/'
export const http = (option) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: baseUrl + option.url,
			method: option.method || 'GET',
			data: option.data || {},
			header: option.header || {},
			success: (res) => {
				if(res.code === 200){
					resolve(res)
				}else{
					uni.showToast({
						title: res.data.msg || '请求失败'
					})
					resolve(res)
				}
			},
			fail: (err) => {
				uni.showToast({
					title:'请求失败'
				})
				reject(err)
			}
		})
	})
}